//
//  CustomTwoBtnvView.m
//  NewChat
//
//  Created by lanou3g on 16/3/3.
//  Copyright © 2016年 蓝鸥. All rights reserved.
//

#import "CustomTwoBtnvView.h"

@implementation CustomTwoBtnvView


-(instancetype)initWithFrame:(CGRect)frame LeftBtnBgColor:(UIColor*)leftcolor RightBtnBgColor:(UIColor*)rightcolor{
    
    
    if (self = [super initWithFrame:frame]) {
        
        [self setBackgroundColor:[UIColor redColor]];
        
        //Button样式使用UIButtonTypeSystem才可以设置setTintColor
        
        self.leftBtn = [UIButton buttonWithType:UIButtonTypeSystem];

        self.leftBtn.backgroundColor = leftcolor;
        self.leftBtn.frame = CGRectMake(0, 0, self.frame.size.width*0.5, self.frame.size.height);
        
        self.rightBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.rightBtn.backgroundColor = rightcolor;
        self.rightBtn.frame = CGRectMake(CGRectGetMaxX(self.leftBtn.frame),0, self.frame.size.width*0.5, self.frame.size.height);
        
        [self addSubview:self.leftBtn];
        [self addSubview:self.rightBtn];

        
    }
    
    return self;
    
}

-(void)setLeftBtnTitle:(nullable NSString *)lefttitle RightBtnTitle:(nullable NSString *)righttitle forState:(UIControlState)state{
    
    [self.rightBtn setTitle:lefttitle forState:state];
    [self.leftBtn setTitle:righttitle forState:state];
    
    
}
    
-(void)setLeftBtnTitleColor:(nullable UIColor *)leftcolor RightBtnTitleColor:(nullable UIColor *)rightcolor{
    
    [self.leftBtn setTintColor:leftcolor];
    [self.rightBtn setTintColor:rightcolor];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
